#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

int n, m;
int a1, b1, c1;
int a2, b2, c2;

int get(int a, int b, int c) {
  if (a || b)
    return 1;
  else if (!c)
    return 2;
  else
    return 0;
}
void solve() {
  cin >> a1 >> b1 >> c1;
  cin >> a2 >> b2 >> c2;
  if (a1 * b2 != a2 * b1)
    cout << 1;
  else {
    int x1 = get(a1, b1, c1);
    int x2 = get(a2, b2, c2);
    if (!x1 || !x2)
      cout << 0;
    else if (x1 == 2 || x2 == 2)
      cout << -1;
    else if (a1 * c2 == a2 * c1 && b1 * c2 == b2 * c1)
      cout << -1;
    else
      cout << 0;
  }
  return;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t;
  t = 1;
  while (t--) solve();
  return 0;
}